define(['angular', 'app', 'ngUiRouter', 'app.services','services/common/base','directives/common/common','directives/jewellery/shared'], function (angular, app,service) {

    'use strict';

    app.config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider) {

        app.loadJs = function(js){
            return function($rootScope, $q){
                var def = $q.defer(), deps=[];
                angular.isArray(js) ? (deps = js) : deps.push(js);
                require(deps,function(){
                    $rootScope.$apply(function(){
                        def.resolve();
                    });
                });
                return def.promise;
            };
        }
        $urlRouterProvider.otherwise(function(){
            return "/common/goods/list"
        });
        /**
         * 基础路由
         */
        $stateProvider.state("common", {
            url: "/common",
            resolve: {
                deps:app.loadJs(['directives/jewellery/jewellery'])
            },
            templateUrl: "/app/partial/jewellery/common.html"
        });
        $stateProvider.state("common.goodsList", {//商品管理列表
            url: "/goods/list",
            template: "<goods-list></goods-list>"
        });
        $stateProvider.state("common.goodsDetail", {//商品详情
            url: "/goodsDetail/:id",
            template: "<goods-detail></goods-detail>"
        });
        $stateProvider.state("common.orderList", {//订单列表
            url: "/orderList",
            template: "<order-list></order-list>"
        });
        $stateProvider.state("common.evaluate", {//订单列表
            url: "/evaluate/:id",
            template: "<evaluate></evaluate>"
        });
        $stateProvider.state("common.shoppingcartList", {//商品管理列表
            url: "/shoppingcart/list",
            template: "<shoppingcart-list></shoppingcart-list>"
        });
        $stateProvider.state("common.myOldList", {//旧物列表
            url: "/myOldList",
            template: "<my-old-list></my-old-list>"
        });
        $stateProvider.state("common.oldGoodsDetail", {//旧物详情
            url: "/oldGoodsDetail/:id",
            template: "<old-goods-detail></old-goods-detail>"
        });
        $stateProvider.state("common.oldGoodsUpdate", {//旧物详情
            url: "/oldGoodsUpdate/:id",
            resolve: {
                deps:app.loadJs(['fileinputLocaleZh'])
            },
            template: "<old-goods-update></old-goods-update>"
        });
        $stateProvider.state("common.oldList", {//旧物列表
            url: "/oldList",
            template: "<old-list></old-list>"
        });
        $stateProvider.state("common.oldGoodsAdd", {//添加旧物页面
            url: "/oldGoodsAdd",
            resolve: {
                deps:app.loadJs(['fileinputLocaleZh'])
            },
            template: "<old-goods-add></old-goods-add>"
        });
        $stateProvider.state("common.couponList", {//优惠券列表
            url: "/coupon",
            template: "<coupon-list></coupon-list>"
        });





        $stateProvider.state("common.imageDetail", {
            url: "/image",
            template:"<image-detail></image-detail>"
        });
    }]);
});